Examples ¶
Example #1 File write example using fflush()

<?php
$filename = 'bar.txt';

$file = fopen($filename, 'r+');
rewind($file);
fwrite($file, 'Foo');
fflush($file);
ftruncate($file, ftell($file));
fclose($file);
?>
See Also ¶
clearstatcache() - Clears file status cache
fwrite() - Binary-safe file write
add a note add a note
User Contributed Notes 2 notes
up
down
6 michaelsy01[NXSPAM] at informantum dot de ¶1 year ago
A hint for PHP beginners like me:
The buffered output which is write by fflush() has nothing to do with the output buffer which is initiated by the ob_start() function.
up
down
-11 jzho327 at cse dot unsw dot edu dot au ¶